package com.star.jersey.mybatisplus.base.core.contract;

import com.star.jersey.mybatisplus.base.core.contract.enums.SortTypeEnum;
import lombok.Data;

/**
 * 排序参数
 */
@Data
public class SortParam {
    // 排序字段
    private String sortField;
    // 排序方式，默认正序asc
    private String sortType;

    public static SortParam asc(String sortField) {
        return new SortParam(sortField, SortTypeEnum.ASC.getCode());
    }

    public static SortParam desc(String sortField) {
        return new SortParam(sortField, SortTypeEnum.DESC.getCode());
    }

    public String getSortField() {
        return this.sortField;
    }

    public String getSortType() {
        return this.sortType;
    }

    public void setSortField(String sortField) {
        this.sortField = sortField;
    }

    public void setSortType(String sortType) {
        this.sortType = sortType;
    }

    public SortParam() {
        this.sortType = SortTypeEnum.ASC.getCode();
    }

    public SortParam(String sortField, String sortType) {
        this.sortType = SortTypeEnum.ASC.getCode();
        this.sortField = sortField;
        this.sortType = sortType;
    }

}